﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;

namespace CCF20Module
{
    [ValueConversion(typeof(bool), typeof(string))]
    public class BoolToStringConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            
            if (parameter == null)
            {
                if ( value != null && (bool)value)
                {
                    return "是";
                }
                else
                {
                    return "否";
                }
            }
            else
            {
                if ((bool)value)
                {
                    return (string)parameter;
                }
                else
                {
                    switch ((string)parameter)
                    {
                        case "等待":
                            return "已确认";
                        default: 
                            return "否";
                    }
                    
                }
                
            }
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            //if (((string)value).Equals("是"))
            //    return true;
            //else
            //    return false;
            return null;
        }
    }
    
}
